diff options
| author | secondl1ght <[email protected]> | 2022-08-22 14:30:03 -0400 |
|---|---|---|
| committer | secondl1ght <[email protected]> | 2022-08-22 14:30:03 -0400 |
| commit | 47873912ae85ab99a4fd462c2cb1541e9ceff316 (patch) | |
| tree | 6dea1fbedb9a59a8e57ceeb3461cea675367a11f /src/routes/[username]/settings | |
| parent | 47fa920b786d1abdf9577fc0854d38cd7514f5c9 (diff) | |
| download | coinos-ui-47873912ae85ab99a4fd462c2cb1541e9ceff316.tar.gz coinos-ui-47873912ae85ab99a4fd462c2cb1541e9ceff316.zip | |
initial hookup of currency rates
Diffstat (limited to 'src/routes/[username]/settings')
| -rw-r--r-- | src/routes/[username]/settings/+page.svelte | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/routes/[username]/settings/+page.svelte b/src/routes/[username]/settings/+page.svelte index 9644c3ac..5ddbfbc4 100644 --- a/src/routes/[username]/settings/+page.svelte +++ b/src/routes/[username]/settings/+page.svelte @@ -1,11 +1,13 @@ <script> import { AppHeader, Icon, Toggle, LocaleSelector } from '$comp'; - import { user, colorTheme } from '$lib/store'; + import { user, colorTheme, rates, token } from '$lib/store'; import { _ } from 'svelte-i18n'; + import { success, failure, post } from '$lib/utils'; let setting = 'account'; let password; let revealPassword = false; + const fiats = Object.keys($rates); const colorThemes = [ { theme: 1, color1: 'from-[#F5F7FA]', color2: 'to-[#C3CFE2]' }, @@ -22,6 +24,19 @@ selectedTheme = colors.theme; $colorTheme = colors.color1 + ' ' + colors.color2; }; + + const updateFiat = async (e) => { + try { + await post( + '/user', + { currency: e.target.value }, + { authorization: `Bearer ${$token}` } + ); + success('Local currency updated!'); + } catch (e) { + failure(e.message); + } + }; </script> {#if $user} @@ -126,8 +141,10 @@ <label for="currency" class="font-bold block mb-1" >{$_('user.settings.localCurrency')}</label > - <select name="currency" class="block py-3 w-full"> - <option value="USD">USD</option> + <select name="currency" on:change={updateFiat} class="block py-3 w-full"> + {#each fiats as fiat} + <option value={fiat} selected={$user.currency === fiat}>{fiat}</option> + {/each} </select> </div> |
